# !/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2021/12/1 11:24
# @Author  : zuodengbo
# @Email   : zuodb@amoydx.com
# @File    : forms
# @Software: PyCharm
# @Desc   : 使用存疑待定
from sanic_wtf import SanicForm
from wtforms import PasswordField, StringField, SubmitField
from wtforms.validators import DataRequired, Length, Regexp


class UsernameFrom(SanicForm):
    username = StringField("username", validators=[
        DataRequired(message="Username is required"),
        Length(min=3, max=20, message="Username length is 3-20, please check it"),
        Regexp(r"^[0-9a-zA-Z_~@$%*&]{3,20}", message="Invalid username")
    ])


class LoginForm(UsernameFrom, SanicForm):
    password = PasswordField("password", validators=[
        DataRequired(message="Password is required"),
        Length(min=32, max=32, message="MD5 password length is 32"),
    ])
    verify_code = StringField("verify_code", validators=[
        DataRequired(message="Verify code is required"),
        Length(min=6, max=6, message="Verify code length is 6")
    ])